import Vue from 'vue'

const SAFE_AREA_INSET_BOTTOM = 34
export default {

	getDeviceType() {
		var isIphoneX = false;
		const res = uni.getSystemInfoSync();
		console.log(JSON.stringify(res) + "---111----222-----3333---");
		const {
			model,
			statusBarHeight
		} = res
		if (
			(model.indexOf('iPhone') > -1 && statusBarHeight > 20) ||
			model.indexOf('iPhone X') > -1 ||
			model.indexOf('iPhone 1') > -1
		) {
			isIphoneX = true;
		} else {
			isIphoneX = false;
		}
		return isIphoneX
	},
	safeAreaHeight() {


		var deviceType = this.getDeviceTypeAndAndroidOrIos();
		if (deviceType == 'ios') {
			var isIphoneX = false;
			isIphoneX = this.getDeviceType();
			return isIphoneX ? SAFE_AREA_INSET_BOTTOM : 0 // 苹果X等机型安全区高度
		} else if (deviceType == 'android') {
			return 0;
		}else if (deviceType == 'pc'){
			return 0;
		}


	},
	getDeviceTypeAndAndroidOrIos() {

		var isPCOS = false
		try {
			let ua = navigator.userAgent.toLowerCase();
			isPCOS = true;
		} catch (e) {
			
			isPCOS = false;
		}
		
		if(isPCOS == true){
			return 'pc'
		}else{
			
			switch (uni.getSystemInfoSync().platform) {
			
				case 'android':
					return 'android'
					break;
			
				case 'ios':
					return 'ios'
					break;
				case 'devtools':
					return 'devtools'
					break;
				default:
					return 'otherDevice'
					break;
			
			}
			
		}

		
	}
}
